﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Xml.Linq;
using System.Configuration.Provider;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Security.Cryptography;
using System.Diagnostics;

namespace DbUtility
{
    public class DatabsaeConnect
    {
        private static readonly string connStr;
        public static Dictionary<string, string> columns;

        public static string ReadJsonFile(string filePath)
        {
            //Debug.WriteLine(filePath);
            // 确保文件存在
            if (File.Exists(filePath))
            {
                // 读取文件内容
                string jsonContent = File.ReadAllText(filePath);
                columns = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonContent);
                string connectionString = "Server=" + columns["Server"] + ";DataBase=" + columns["Database"] + ";Uid=" + columns["Username"] + ";pwd=" + columns["Password"];
                // 打印连接字符串
                Console.WriteLine(connectionString);
                //Debug.WriteLine(connectionString);
                return connectionString;
            }
            return null;
        }

    }
}
